package cate.game.play.buff.h;


import cate.game.play.buff.BuffHandler;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.round.RoundCtx;
import cate.game.play.skill.Skill;
import easy.java.dev.note.NoteClass;

import java.util.Collections;
import java.util.List;

@NoteClass("混乱")
public class 混乱BH extends BuffHandler {

	//行动时只会用普通攻击，攻击全场随机1个单位，持续2个回合，可以被驱散
	@Override
	public boolean forceUseAttack(RoundCtx round, Skill skill) {
		Fighter target = findTarget(round);
		if (target == null) {
			return false;
		}
		skill.param.addAppointTarget(target);
		return true;
	}

	private Fighter findTarget(RoundCtx round) {
		List<Fighter> targets = buff.owner.getFightTeam().getFriendsAlive(buff.owner);
		targets.addAll(round.getTeamVs().getEnemyTeam(buff.owner.getTeam()).getFightersAlive());
		if (targets.isEmpty()) {
			return null;
		} else {
			Collections.shuffle(targets);
			return targets.get(0);
		}
	}
}
